#ifndef AAAATTRBUTE_H
#define AAAATTRBUTE_H

#include <string>
#include <memory>

enum class EAttrType : uint8_t
{
    NONE_TYPE = 0,
    USER_NAME = 1,
    USER_PASS = 2,
    NAS_IDENTIFIER = 32,
};

#pragma pack( push )
#pragma pack(1)
struct SAttrPack
{
    EAttrType typePlace;
    uint8_t lengthPlace;
};
#pragma pack(pop)


class AAAAttrbute
{
public:
    AAAAttrbute() = default;
    ~AAAAttrbute() = default;
    AAAAttrbute( const AAAAttrbute& other );

    EAttrType type() const;
    void setType(const EAttrType type);

    uint8_t length() const;

    std::string val() const;
    void setVal( const void* data, uint8_t len );

    /**
     * @brief pack  把数据打包到一块内存，组成2 进制协议。
     * @param data [out] 指向数据开始的内存
     * @param len [out] 数据的长度
     * @return　true 成功，false 有数据没有初始化
     */
    bool pack( uint8_t*& data, uint8_t& dataLen );

    void print( void );
  private:
    EAttrType _type = EAttrType::NONE_TYPE; ///< 包类型
    uint8_t _length = sizeof( SAttrPack );				///< 长度
    std::string _val = "";				///< 数据段
    std::shared_ptr<uint8_t> _pbuf = nullptr;
};

#endif // AAAATTRBUTE_H
